// ChCConnectionSettingsDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ChatClient.h"
#include "ChCConnectionSettingsDlg.h"


// CChCConnectionSettingsDlg dialog

IMPLEMENT_DYNAMIC(CChCConnectionSettingsDlg, CDialog)

CChCConnectionSettingsDlg::CChCConnectionSettingsDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CChCConnectionSettingsDlg::IDD, pParent)
	, m_strHostName(_T(""))
	, m_uPort(0)
{

}

CChCConnectionSettingsDlg::~CChCConnectionSettingsDlg()
{
}

void CChCConnectionSettingsDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, m_strHostName);
	DDX_Text(pDX, IDC_EDIT2, m_uPort);
	DDV_MinMaxUInt(pDX, m_uPort, 1, 99999);
}

INT_PTR CChCConnectionSettingsDlg::SetupSettings()
{
	CChCConnectionSettingsDlg dlg;
	CChCSettings *pSettings = CChCSettings::Instance();
	pSettings->ReadSetings();
	dlg.HostName(pSettings->HostName());
	dlg.Port(pSettings->Port());
	
	INT_PTR nRet = dlg.DoModal();
	if(IDOK == nRet)
	{
		pSettings->HostName(dlg.HostName());
		pSettings->Port(dlg.Port());
		pSettings->SaveSettings();
	}

	return nRet;
}


BEGIN_MESSAGE_MAP(CChCConnectionSettingsDlg, CDialog)
END_MESSAGE_MAP()


// CChCConnectionSettingsDlg message handlers
